# _*_ coding: utf-8 _*_
# @Time : 2024-01-15 21:20
# @Author : wf

import urllib.request as request
import http.client

url = 'https://www.baidu.com'

# user_agent限制 反扒
# response = request.urlopen(url)
# content = response.read().decode("utf8")
# print(content)

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
}
# 关键字传参
req = request.Request(url, headers=headers)
response: http.client.HTTPResponse = request.urlopen(req)
content = response.read().decode("utf8")
print(content)
